<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >

    <ui:composition template="layout.xhtml">
        <ui:define name="corpo">
            <h:form id="criarSecao" acceptcharset="utf-8"> 
                <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('indexProtocolo.xhtml')}" value="Protocolo" update="@form" immediate="true"/> >
                    <p:commandLink  value="Tramitar" update="@form" immediate="true"/>
                </div>
                <p:panel header="Recebimento de Protocolo">
                    <p:messages id="msg" autoUpdate="true"/>

                    <h:panelGrid columns="2" border="0" styleClass="textAlignRight" columnClasses="textAlignRight"> 
                        <h:outputLabel value="Código do Protocolo: "/>
                        <p:inputText value="#{managerReceberProtocolo.cod}"
                                     id="protocoloInput"
                                     onblur="searchProtocolo()"
                                     size="41"  converterMessage="Código inválido">
                            <f:convertNumber type="number" />
                        </p:inputText>
                         <p:remoteCommand name="searchProtocolo" 
                                     update="@form" 
                                     process="protocoloInput"
                                     actionListener="#{managerReceberProtocolo.protocoloFind()}" /> 
                    </h:panelGrid>  
                    

                    <fieldset class="ui-fieldset">
                        <legend>Protocolos </legend> 
                        <p:dataTable var="traRcb" 
                                     value="#{managerReceberProtocolo.tramiteModel}" 
                                     rowKey="#{traRcb.id}"
                                     selection="#{managerReceberProtocolo.tramites}"
                                     style="width: 100%; display: inline-block;" 
                                     styleClass="check" paginator="true" rows="10"
                                     paginatorPosition="bottom" 
                                     paginatorTemplate="{PageLinks}" emptyMessage="Nenhum Trâmite encontrado"
                                     > 

                            <p:column selectionMode="multiple" />  

                            <p:column headerText="Protocolo" style="width: 15%" >
                                 <h:outputText value="#{traRcb.protocolo.id}"/>
                            </p:column>  
                            
                            <p:column headerText="Unidade Destino" style="width: 30%" >
                                 <h:outputText value="#{traRcb.destino.nome}"/>
                            </p:column>
                            <p:column headerText="Usuário de Destino" style="width: 30%" >
                                 <h:outputText value="#{traRcb.usrDestino.nome}"/>
                            </p:column>
                            
                            <p:column headerText="Unidade Origem" style="width: 30%" >
                                 <h:outputText value="#{traRcb.remetente.nome}"/>
                            </p:column>
                            <p:column headerText="Usuário de Origem" style="width: 30%" >
                                 <h:outputText value="#{traRcb.usrRemetente.nome}"/>
                            </p:column>
                            
                            <p:column headerText="Data da Tramitação" style="width: 30%" >
                                 <h:outputText value="#{traRcb.dataCad}">
                                       <f:convertDateTime pattern="dd/MM/yyyy"/>
                                 </h:outputText>
                            </p:column>  

                        </p:dataTable>



                    </fieldset>

                    <div class="buttonAction">
                        <p:commandButton id="id_submit"  icon="ui-icon-disk" 
                                         value="Receber" actionListener="#{managerReceberProtocolo.receber()}"
                                         update="@form" process="@form" />
                        <p:commandButton value="Cancelar" icon="ui-icon-arrowreturnthick-1-w" 
                                         actionListener="#{managerIndex.redirect('indexCorSelo.xhtml')}" 
                                         immediate="true"/>
                    </div>

                </p:panel>   
                <p:ajaxStatus style="width:16px;height:16px;" id="ajaxStatusPanel">  
                    <f:facet name="start">  
                        <h:graphicImage value="/media/img/loading.gif" />  
                    </f:facet>  

                    <f:facet name="complete">  
                        <h:outputText value="" />  
                    </f:facet>  
                </p:ajaxStatus>
            </h:form>
        </ui:define>
    </ui:composition> 
</html>